#include "FileDownloader.h"
#include <QNetworkRequest>
#include <QDebug>
//
FileDownloader::FileDownloader(  ) 
	: QObject()
{
	// TODO
}
//
FileDownloader::~FileDownloader()
{
}
//
void FileDownloader::download(QString url){
	QNetworkRequest request;
	QNetworkAccessManager *manager = new QNetworkAccessManager(this);
	
	connect(manager,	SIGNAL(finished(QNetworkReply*)),
			this, 		SLOT(networkReply(QNetworkReply*)));
	request.setUrl(url);
	// Faking FF 3.0.1
	request.setRawHeader("User-Agent", "# Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071719 Firefox/3.0.1");
	manager->get(request);
}

void FileDownloader::networkReply(QNetworkReply* reply){
	//qDebug()<<"Reply received!"<<endl;
	QString str = reply->readAll();
	emit	fileDone(str);
}
